/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.SimpleTime;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Kernel.NamedElement;

import edu.pku.sei.modeler.model.uml.Kernel.ValueSpecification;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Duration extends ValueSpecification implements IDuration {
	// attributes
	
	protected boolean firstTime;
	
	
	
	
	// references
	
	protected MetaTypedList event;
	
	
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "DURATION_FIRSTTIME",
			catalog = "Model",
			name = ModelPackage.DURATION_FIRSTTIME,
			setter = "setfirstTime"
			)
	
	public boolean getFirstTime() {
		return firstTime;
	}
	public void setFirstTime(boolean newFirstTime) {
		boolean oldfirstTime = firstTime;
		firstTime = newFirstTime;
		firePropertyChange(ModelPackage.DURATION_FIRSTTIME, oldfirstTime, newFirstTime);
	}
	
	// getters for references
	
	public MetaTypedList getEvent() {
		if(event == null) {
			event = new MetaTypedList(NamedElement.class, this, ModelPackage.DURATION_EVENT);
		}
		return event;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.DURATION_FIRSTTIME, firstTime);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.DURATION_EVENT, event);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		firstTime = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.DURATION_FIRSTTIME);
		
		// references
		
		this.getEvent().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.DURATION_EVENT, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.DURATION_EVENT.equals(featureID)) {
			getEvent().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 